import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    emp: {},
    pwd: ''
  },
  getters: {
    getNowDate() {
      let toDate = new Date()
      let year = toDate.getFullYear()
      let month = toDate.getMonth() + 1
      if(month < 10) {
        month = "0" + month
      }
      let date = toDate.getDate()
      if(date < 10) {
        date = "0" + date
      }
      return year + "-" + month + "-" + date
    }
  },
  mutations: {
    setEmp(state, emp) {
      state.emp = emp
      if(emp.job == 3){
        state.emp.job = 'emp'
      } else if(emp.job == 2) {
        state.emp.job = 'manager'
      } else {
        state.emp.job = 'admin'
      }
    },
    setPwd(state, pwd) {
      state.pwd = pwd
    }

  },
  actions: {
  },
  modules: {
  }
})
